// ColumnModels
var alertEventPublishedGrid_cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
			header : '提醒事件ID',
			dataIndex : 'alertEventId',
			sortable : true,
			hidden : true,
			width : 50
		}, {
			header : '事件标题',
			dataIndex : 'eventTitle',
			width : 100,
			sortable : true,
			locked : false
		}, {
			header : '时间',
			dataIndex : 'alertTime', 
			width : 140,
			sortable : true,
			renderer: 
				function(v){
					var JsonDateValue;
			        if (Ext.isEmpty(v))
			        	return ' ';
			        else if (Ext.isEmpty(v.time))
			        	JsonDateValue = new Date(v);
			        else
			        	JsonDateValue = new Date(v.time);
			        return JsonDateValue.format('Y-m-d');
				}
		}, {
			header : '接收者工号',
			dataIndex : 'eventAlertMan',
			width : 100
		}, {
			header : '接收者姓名',
			dataIndex : 'spareField1',
			width : 100
		}, {
			header : '对方是否已读',
			dataIndex : 'isRead',
			renderer : readfunction,
			width : 140
		}, {
			header : '操作',
			dataIndex : 'alertEventId',
			renderer : eventPublishedAction,
			width : 200
		}])
function readfunction(val){
	switch(val){
	case "0":
		return "未读";
	case "1":
		return "已读";
	default:
		return "已读";
	}
}
function eventPublishedAction(val,cellmeta,record,rowIndex,columnIndex,store){
	var content = record.get("eventContent");
	view = "viewEventPublishedContent('" + content + "');return false;";
	a = ' <a href="#" onclick="'+ view +'">查看内容</a>&nbsp;';
	del = "deleteEventPublished('" + val + "');return false;";
	b = ' <a href="#" onclick="'+ del +'">删除记录</a>&nbsp;';
	return a + b;
}
function viewEventPublishedContent(val){
	var contentWindow = new Ext.alertContentWindow();
	contentWindow.findById("alertContentTextArea").setValue(val);
	contentWindow.show();
}
function deleteEventPublished(val){
	Ext.MessageBox.confirm("确认删除","你确认要删除所选记录吗？",function(btn){
		if(btn == "yes"){
			Ext.Ajax.request({
				url : 'projectManage/projectManageAction!delAlertEventPub',
				success : function(response,options){
	 				var r = Ext.decode(response.responseText);
	 				if(r.success){
	 					Ext.Msg.alert("操作成功","删除记录成功！");
	 					alertEventPublishedStore.reload();
	 				}else{
	 					Ext.Msg.alert("操作失败","请重新操作！");
	 				}
	 				
	 			},
	 			failure : function(){
	 				Ext.Msg.alert("操作失败","请重新操作！");
	 			},
				params : {
					pageMessage4 : val
				}
			});
		}
	});
}
Ext.alertEventPublishedGrid = Ext.extend(Ext.grid.GridPanel,{
	initialized:false,
	loadMask : true,
	loadData:function(){
	this.store.load({
		params:{
		start:0,
		limit:20
	}
	});
},
	initComponent:function(){
		this.store = alertEventPublishedStore;
		this.stripeRows = true; 
		this.cm = alertEventPublishedGrid_cm;
		this.tbar = [new Ext.inquryAlertEventPubCombobox({
			id: 'inquryAlertEventPubCombobox_id',
			width : 100
		}),new Ext.inquryAlertEventButton({
			id:'inquryAlertEventButton_pub',
			handler : function(b,e){
			var a = b.findParentBy(function(ct, cmp) { 
				return (ct instanceof Ext.grid.GridPanel) ? true : false; 
			});
			var combo_value = a.getTopToolbar().findById("inquryAlertEventPubCombobox_id").getValue();
//			var text_value = a.getTopToolbar().findById("pm_inquryProjectSuperviseTextfield_id").getValue();
			alertEventPublishedStore.on('beforeload',function(){
				alertEventPublishedStore.baseParams = {
						pageMessage2 : getLoginJobNumber(),
						type : combo_value
					}
				});
			alertEventPublishedStore.load({
					params : {
						start : 0,
						limit : 20,
						pageMessage2 : getLoginJobNumber(),
						type : combo_value
				}
				});
				
			
		}
		}),new Ext.Button({
			id : 'newAlertEvent',
			margin : 'centre',
			text : '发布提醒事件',
			handler : function(b,e){
				var publishWindow = new Ext.newAlertEventWindow();
				publishWindow.show();
			}
		})];
		this.bbar = new Ext.PagingToolbar({
			pageSize : 20,
			store : this.store,
			displayInfo : true,
			displayMsg : '显示 {0}-{1}条 / 共 {2} 条',
			emptyMsg : "无数据。",
			plugins : [new Ext.ux.PageSizePlugin()],
			items : ['-']
		});
        Ext.alertEventPublishedGrid.superclass.initComponent.call(this);
              
}
})















